package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseGradebook extends SQLiteOpenHelper {

	private String tableName=null;
	public final String ID="GradebookID";
	public final String ItemName="GradebookItemName";
	public final String MarksObtained="GradebookMarksObtained";
	public final String Remark="GradebookRemark";
	public final String MaxMarks="GradebookMaxMarks";
	public final String HighestLowestMarks="GradebookHighestLowestMarks";
	public final String AverageMedianMarks="GradebookAverageMedianMarks";
	public final String Percentile="GradebookPercentile";
	public final String DateEntered="GradebookDateEntered";
	public final String CategoryTitle="GradebookCategoryTitle";
	public final String CourseCode="GradebookCourseCode";
	
	public DatabaseGradebook(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "+ tableName +" ( "+ ID + " TEXT PRIMARY KEY , "+
				  ItemName + " TEXT, " + MarksObtained + " TEXT, " + Remark + " TEXT, " + MaxMarks + 
				  " TEXT, " + HighestLowestMarks + " TEXT, " + AverageMedianMarks + " TEXT, " + Percentile + " TEXT, " + 
				  DateEntered + " TEXT, " + CourseCode + " TEXT, " + CategoryTitle + " TEXT)"
				  );
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
		 }
}
